package com.example.nophase.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.nophase.R;
import com.example.nophase.entity.OaCommonAuditBean;
import com.example.nophase.entity.ProjectDetailDTO;

import java.text.SimpleDateFormat;
import java.util.List;

public class ApplyForFromProjectListAdapter extends BaseAdapter {


    List<ProjectDetailDTO> list;
    Context context;

    public ApplyForFromProjectListAdapter(List<ProjectDetailDTO> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        if (position == getCount() || list == null) {
            return null;
        }
        return list.get(position);

    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {

        View view= LayoutInflater.from(context).inflate(R.layout.apply_form_project_lv_item, null);
        TextView title = view.findViewById(R.id.applyfor_lv_item_title);
        TextView money = view.findViewById(R.id.applyfor_lv_money);
        TextView adult = view.findViewById(R.id.adult_lv_money);
        ProjectDetailDTO item = list.get(position);
        String project_plan = "";
        if (item.getAppStep() != null) {
            if (!item.getAppStep().equals("")) {
                project_plan = "(" + item.getAppStep() + ")";
            }
        }
        title.setText(item.getProName()+project_plan);
        money.setText(String.valueOf(item.getAppMoney()));
        adult.setText(String.valueOf(item.getAuditMoney()));

        return view;
    }

}
